package org.pine.batch.batch;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameter;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author liucs
 */
@RestController
public class HelloController {
    JobLauncher jobLauncher;
    @Autowired
    public void setJobLauncher(JobLauncher jobLauncher) {
        this.jobLauncher = jobLauncher;
    }

    Job job;
    @Autowired
    public void setJob(Job job) {
        this.job = job;
    }

    @GetMapping("/hello")
    public void hello() {
        try {
            JobParameters jobParameter= new JobParameters();
            jobLauncher.run(job,  jobParameter);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
